﻿using System;

namespace DotNetCommon.Validate.Annotations;

/// <summary>
/// 表示不能是其中之一, 示例:
/// <code>
/// [VNotIn([1, 2])]
/// public int Ids { get; set; }
/// </code>
/// </summary>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public class VNotInAttribute(object[] values, string errorMessage = null) : Attribute, IValidateAction
{
    public object[] Values { get; internal set; } = values;
    public string ErrorMessage { get; internal set; } = errorMessage;

    public void Action(IValidateContext ctx)
    {
        ValidateExtensions.MustNotInInternal(ctx, Values, ErrorMessage);
    }
}
